package com.ytjj.quartz.service;

import com.ytjj.common.service.RedisService;
import com.ytjj.quartz.dao.ImDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class ImService {

    @Resource
    private ImDao imDao;
    @Resource
    private RedisService redisService;

    public void imUserOffLine() {
        //所有客服user_id查出来
        List<String> emailList = imDao.selectAllUser();
        if (CollectionUtils.isEmpty(emailList)) {
            return;
        }
        emailList.stream().forEach(item -> {
            imDao.updateServiceUserStatusUpline(item);
            redisService.set("im:service:status:" + item, "3");
        });
//        emailList.forEach(item ->{
//            ImServiceUserDto imServiceUserDto = new ImServiceUserDto();
//            imServiceUserDto.setUserId(item);
//            imServiceUserDto.setStatus((byte) 3);
//            adminClient.updateUserStatusByRpc(imServiceUserDto);
//        });
    }
}
